Skip to content

feat: more generic url #2556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat: more generic url #2556

wants to merge 5 commits into from

Conversation

racinmat
Copy link

@racinmat racinmat commented Aug 15, 2025

Fixes #2238.
Makes the logic changed by #2520 flexible and usable by agents defined in the same application.
Supersedes #2251 because that did not get requested for review and adk-bot was not triggered there for some reason.
This is more generic and allows you to set http or https as needed, which is crucial in larger ecosystems.
And it lets you nest the FastAPI into a subapp, because you can specify the base url including the path of the sub-app.

If the url parameter in agent card is empty string, it will be filled from the application. This lets you either hardcode the agent url or let it be defined from the code.

testing plan

The tests can be seen in the PR.
I removed the mock to actually exercise the A2A-related code which was just silently crashing until now.

Now, with this with, you can run

from pathlib import Path
import uvicorn
from fastapi import FastAPI
from google.adk.cli.fast_api import get_fast_api_app
app = FastAPI()
adk_app = get_fast_api_app(
    agents_dir=str((Path(__file__) / '..').absolute()),
    session_service_uri="sqlite:///:memory:",
    allow_origins=["*"],
    web=True,
    base_url="http://127.0.0.1:8081/adk",
)
app.mount("/adk", adk_app)
uvicorn.run(app, host="0.0.0.0", port=8081)

and the a2a agent will be exposed on the localhost. And if you will run the code in different environments, you can parameterize them now, and pass the URL e.g. from environment variable, which wasn't possible after merging #2520.

@adk-bot adk-bot added bot triaged [Bot] This issue is triaged by ADK bot tools [Component] This issue is related to tools labels Aug 15, 2025
@adk-bot adk-bot requested a review from seanzhou1023 August 15, 2025 08:23
@adk-bot
Copy link
Collaborator

adk-bot commented Aug 15, 2025

Response from ADK Triaging Agent

Hello @racinmat, thank you for creating this PR!

To help reviewers better understand and test your changes, could you please add a testing plan section to your PR description? You can find more details in our contribution guidelines.

Thanks!

@racinmat racinmat marked this pull request as draft August 15, 2025 20:57
@racinmat racinmat marked this pull request as ready for review August 15, 2025 21:20
@racinmat
Copy link
Author

racinmat commented Aug 15, 2025

@adk-bot I modified description of the PR by adding testing plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot triaged [Bot] This issue is triaged by ADK bot tools [Component] This issue is related to tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A2A agent cards do not support mounting adk as a fastapi sub-app and https.
2 participants